// 设置测试环境变量
process.env.NODE_ENV = 'test';

// 导入统一配置模块
const config = require('../config/config');

// 导入数据库连接
const { sequelize } = require('../config/database');

// 打印测试环境配置信息（可选，用于调试）
console.log(`Running tests in ${config.env} environment`);
console.log(`Using database: ${config.db.host}:${config.db.port}/${config.db.database}`);

// 测试完成后关闭数据库连接
afterAll(async () => {
  try {
    await sequelize.close();
    console.log('Test database connection closed');
  } catch (error) {
    console.error('Error closing database connection:', error);
  }
});